//
//  TcpConnector.h
//  socketDemo
//
//  Created by 吳瀾洲 on 2020/8/7.
//  Copyright © 2020 kingboyrang. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "GCDAsyncSocket.h"
#import "TcpConfigDefine.h"
#import "BaseDataPack.h"

NS_ASSUME_NONNULL_BEGIN


@protocol TcpConnectorDelegate <NSObject>

@optional
//连接状态
- (void)didConnectHostState:(TcpConnectState)conState;
//发送成功回调
- (void)didSendDataState:(BOOL)success tag:(long)tag error:(NSError *)error;

@end


@interface TcpConnector : NSObject<GCDAsyncSocketDelegate>

@property (nonatomic, strong) GCDAsyncSocket *socket;

@property (nonatomic,assign) id<TcpConnectorDelegate> delegate; //代理

//连接状态
@property (nonatomic,copy) TcpConnectStateChangedBlock connectStateChangedBlock;
//发送数据状态
@property (nonatomic,copy) TcpSendDataStateBlock sendDataStateBlock;

/**
 * @brief 发送数据报文
 * @param aDataPack 数据报文
 */
- (BOOL)sendDataPack:(BaseDataPack*)aDataPack;


@end

NS_ASSUME_NONNULL_END
